package behaviors;

import lejos.nxt.LCD;
import lejos.nxt.Motor;
import lejos.nxt.comm.RConsole;
import lejos.robotics.Color;

import lejos.robotics.subsumption.Behavior;
import lejos.util.PilotProps;
import model.SBOne;

public class Rotate extends Thread  implements Behavior {

	private boolean suppressed= false;
	
	private static  SBOne r_SBOne;

	public Rotate(){
		r_SBOne = SBOne.getInstance();
	}
	
	@Override
	public boolean takeControl() {

		LCD.drawString("", 0, 3);
		LCD.drawString("RT TC " + r_SBOne.getColorID(), 0, 0);	
		if (r_SBOne.getColorID() == 0 || r_SBOne.isFindDirection()) // 0== RED
			return false;
		return true;
		
	}

	@Override
	public void action() {
		LCD.drawString("RT AC", 0, 1);
		int sweep = 15;
		try {
			r_SBOne.rotate(sweep, true);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			// TODO Auto-generated catch block
		
		suppressed = false;

	}

	@Override
	public void suppress() {
		r_SBOne.stop();
		suppressed = true;
	}


}
